package com.zendaimoney.test.simulation.action.baofoopay;

import com.zendaimoney.test.simulation.action.BaseAction;
import com.zendaimoney.test.simulation.annotation.RequestCategory;
import com.zendaimoney.test.simulation.enums.ThirdType;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@RequestCategory(thirdType = ThirdType.BAOFOOPAY, bizType = "")
@Component("com.zendaimoney.test.simulation.action.baofoopay.QuickCollectAction")
@Slf4j
public class QuickCollectAction extends BaseAction{

    public static final String aesKey = "yhgt51gfr2jut50a";

    @Override
    @SneakyThrows
    public String process(String requestInfo) {
        /*
        log.info("通联快捷支付代收接口");
        QuickCollectReq request = new QuickCollectReq();
        request = (QuickCollectReq)parseMessage(request, requestInfo);
        log.info("request:{}", request.toString());

        String send_time1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());//报文发送日期时间

        Map<String,String> dataMap1 = new TreeMap<String,String>();
        dataMap1.put("send_time", send_time1);
        dataMap1.put("msg_id", "TISN" + System.currentTimeMillis());//报文流水号
        dataMap1.put("version", "4.0.0.0");
        dataMap1.put("resp_code", PlatformRespCode.AllinPay.SUCCESS.getHeadCode()); 				// todo 自己写
        dataMap1.put("terminal_id", "200001173");
        dataMap1.put("txn_type", "01");//交易类型
        dataMap1.put("member_id", "100000276");
        dataMap1.put("biz_resp_code", PlatformRespCode.AllinPay.SUCCESS.getBodyCode());			// todo 自己写
        dataMap1.put("biz_resp_msg", PlatformRespCode.AllinPay.SUCCESS.getBodyMsg());			// todo 自己写

        // 唯一码
        String uniqueCode = UUID.randomUUID().toString().substring(0,10);
        log.info("唯一码明文：" + uniqueCode);
        uniqueCode = SecurityUtil.AesEncrypt(SecurityUtil.Base64Encode(uniqueCode), aesKey);
        dataMap1.put("unique_code",uniqueCode);
        log.info("唯一码加密：" + uniqueCode);

        // 数字信封
        String dgtl = "01|" + aesKey;
        log.info("数字信封明文：" + dgtl);
        dgtl = RsaCodingUtil.encryptByPubCerFile(SecurityUtil.Base64Encode(dgtl), baofooPublicFile);
        dataMap1.put("dgtl_envlp", dgtl);
        log.info("数字信封加密：" + dgtl);

        // 制作签名
        String SignVStr = FormatUtil.coverMap2String(dataMap1);
        String signature = SecurityUtil.sha1X16(SignVStr, "UTF-8");//签名
        String Sign = SignatureUtils.encryptByRSA(signature, baofooPrivateFile, baofooPrivatePwd);
        dataMap1.put("signature", Sign);
        log.info("签名：" + Sign);

        String response = FormatUtil.coverMap2String(dataMap1);
        log.info("宝付模拟报文返回：" + response);
        
        return response;
        */

        return null;
    }
}
